package com.iims.flowable.flow.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.iims.common.utils.StringUtils;
import lombok.Data;

import java.io.Serializable;
import java.nio.charset.Charset;
import java.util.Date;

/**
 * @TableName cmis_flow_task_form
 */
@TableName(value = "cmis_flow_task_form")
@Data
public class FlowTaskForm implements Serializable {
    /**
     * 任务id
     */
    @TableField("TASK_ID_")
    private String taskId;

    /**
     * 表单KEY
     */
    @TableField("FORM_KEY_")
    private String formKey;

    /**
     * 任务节点名称
     */
    @TableField("TASK_NAME_")
    private String taskName;

    /**
     * 流程定义Id
     */
    @TableField("PROC_DEF_ID_")
    private String procDefId;

    /**
     * 流程实例id
     */
    @TableField("PROC_INST_ID_")
    private String procInstId;

    /**
     * 创建时间
     */
    @TableField("CREATE_TIME_")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @TableField("CREATE_BY_")
    private String createBy;

    /**
     * 表单(动态表单带数据)
     */
    @TableField("FORM_DATA_BACK_")
    private byte[] formDataBack;

    /**
     * 业务json数据
     */
    @TableField("FORM_DATA_JSON_")
    private byte[] formDataJson;


    public void setFormDataBack(String formDataBack) {
        this.formDataBack = StringUtils.getBytes(formDataBack, Charset.forName("UTF-8"));
    }

    public void setFormDataJson(String formDataJson) {
        this.formDataJson = StringUtils.getBytes(formDataJson, Charset.forName("UTF-8"));
    }

    public String formDataBackStr() {
        return StringUtils.toEncodedString(formDataBack, Charset.forName("UTF-8"));
    }

    public String formDataJsonStr() {
        return StringUtils.toEncodedString(formDataJson, Charset.forName("UTF-8"));
    }

}